//引入菜单的接口方法
import { Message } from "element-ui";
import { rolelist } from "../../request/api";

export default {
    state: {
        roleList: [],//这是role的初始数组
        is: {//判断是否显示dialog 弹窗
            show: false
        }
    },
    getters: {},
    mutations: {
        //修改role数据 初始数据
        REQ_ROLE(state, payload) {
            state.roleList = payload;
        },
        //修改dialog弹窗
        changeDialog(state, payload) {
            state.is.show = payload;
        }
    },
    actions: {
        //异步操作 获取数据 role
        getRole({commit}){
            rolelist().then(res=>{
                if(res.code==200){
                    commit('REQ_ROLE',res.list);
                    // console.log(res.list,'vuex打印');
                }else{
                    Message.error(res.msg);
                }
            })
        }
      
    },
    namespaced: true
}